{% extends 'warehouse/base.html' %}

{% block title %}出库记录列表{% endblock %}

{% block content %}
<div class="row">
    <div class="col-md-12">
        <h1>出库记录列表</h1>
        
        {% if messages %}
            {% for message in messages %}
                <div class="alert alert-{{ message.tags }} alert-dismissible fade show" role="alert">
                    {{ message }}
                    <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
                </div>
            {% endfor %}
        {% endif %}
        
        <div class="card">
            <div class="card-header">
                <h3>所有出库记录</h3>
                {% if 'outbound_create' in user_permissions %}
                <a href="{% url 'warehouse:outbound_create' %}" class="btn btn-primary float-end">创建出库记录</a>
                {% endif %}
            </div>
            <div class="card-body">
                <p><strong>数据库状态:</strong> {{ db_status }}</p>
                
                <table class="table table-striped">
                    <thead>
                        <tr>
                            <th>商品</th>
                            <th>数量</th>
                            <th>客户</th>
                            <th>审批人</th>
                            <th>操作员</th>
                            <th>操作时间</th>
                        </tr>
                    </thead>
                    <tbody>
                        {% for outbound in outbound_list %}
                        <tr>
                            <td>{{ outbound.goods.name }}</td>
                            <td>{{ outbound.quantity }} {{ outbound.goods.unit }}</td>
                            <td>{{ outbound.customer }}</td>
                            <td>{{ outbound.approver.username }}</td>
                            <td>{{ outbound.operator.username }}</td>
                            <td>{{ outbound.operation_time|date:"Y-m-d H:i" }}</td>
                        </tr>
                        {% empty %}
                        <tr>
                            <td colspan="6">暂无出库记录</td>
                        </tr>
                        {% endfor %}
                    </tbody>
                </table>
            </div>
        </div>
        
        <div class="mt-3">
            <a href="{% url 'warehouse:dashboard' %}" class="btn btn-secondary">返回仪表盘</a>
        </div>
    </div>
</div>
{% endblock %}